package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingInteractiveComments;
import com.ruoyi.ring.service.IRingInteractiveCommentsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 互动评论Controller
 * 
 * @author liuwp
 * @date 2025-11-21
 */
@RestController
@RequestMapping("/ring/ring_interactive_comments")
public class RingInteractiveCommentsController extends BaseController
{
    @Resource
    private IRingInteractiveCommentsService ringInteractiveCommentsService;

    /**
     * 查询互动评论列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_comments:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingInteractiveComments ringInteractiveComments)
    {
        startPage();
        List<RingInteractiveComments> list = ringInteractiveCommentsService.selectRingInteractiveCommentsList(ringInteractiveComments);
        return getDataTable(list);
    }

    /**
     * 导出互动评论列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_comments:export')")
    @Log(title = "互动评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingInteractiveComments ringInteractiveComments)
    {
        List<RingInteractiveComments> list = ringInteractiveCommentsService.selectRingInteractiveCommentsList(ringInteractiveComments);
        ExcelUtil<RingInteractiveComments> util = new ExcelUtil<RingInteractiveComments>(RingInteractiveComments.class);
        util.exportExcel(response, list, "互动评论数据");
    }

    /**
     * 获取互动评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_comments:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringInteractiveCommentsService.selectRingInteractiveCommentsById(id));
    }

    /**
     * 新增互动评论
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_comments:add')")
    @Log(title = "互动评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingInteractiveComments ringInteractiveComments)
    {
        return toAjax(ringInteractiveCommentsService.insertRingInteractiveComments(ringInteractiveComments));
    }

    /**
     * 修改互动评论
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_comments:edit')")
    @Log(title = "互动评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingInteractiveComments ringInteractiveComments)
    {
        return toAjax(ringInteractiveCommentsService.updateRingInteractiveComments(ringInteractiveComments));
    }

    /**
     * 删除互动评论
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_interactive_comments:remove')")
    @Log(title = "互动评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringInteractiveCommentsService.deleteRingInteractiveCommentsByIds(ids));
    }
}
